/**
 * 
 */
var tpl = require('./index.html');
//var style = require('./index.css');

module.exports = function(mod, name) {
	mod.directive(name, function() {
		return {
			restrict: 'EA',
			replace: true,
			transclde: true,
			scope: {
				seedListArrays: '=seedListArrays'
				
			},
			template: tpl,
			link: function(scope, element, attrs) {
				
				scope.saveSeedEdit = function() {
					
					scope.seedParams = new Object();
					scope.seedParamsId = {id : document.getElementsByTagName('input')[0].value};
//					scope.seedParams.id = document.getElementsByTagName('input')[0].value;
					
					scope.seedParams.site_id  = document.getElementsByTagName('input')[1].value;
					scope.seedParams.site_name = document.getElementsByTagName('input')[2].value;
					scope.seedParams.url = document.getElementsByTagName('input')[3].value;
					scope.seedParams.mode = document.getElementsByTagName('input')[4].value;
//					
					scope.seedParams.download_type  = document.getElementsByTagName('input')[5].value;
					scope.seedParams.priority = document.getElementsByTagName('input')[6].value;
					scope.seedParams.doc_type  = document.getElementsByTagName('input')[7].value;
					scope.seedParams.page_num  = document.getElementsByTagName('input')[8].value;
					scope.seedParams.check_body  = document.getElementsByTagName('input')[9].value;
//					
					scope.seedParams.check_body_not  = document.getElementsByTagName('input')[10].value;
					scope.seedParams.check_size  = document.getElementsByTagName('input')[11].value;
					scope.seedParams.timeout  = document.getElementsByTagName('input')[12].value;
					scope.seedParams.max_tries  = document.getElementsByTagName('input')[13].value;
					scope.seedParams.proxy_time = document.getElementsByTagName('input')[14].value;
					
					scope.seedParams.crawl_item  = document.getElementsByTagName('input')[15].value;
					scope.seedParams.item_check_body  = document.getElementsByTagName('input')[16].value;
					scope.seedParams.item_check_body_not  = document.getElementsByTagName('input')[17].value;
					scope.seedParams.item_download_type  = document.getElementsByTagName('input')[18].value;
					scope.seedParams.cat = document.getElementsByTagName('input')[19].value;
					
					scope.seedParams.is_once  = document.getElementsByTagName('input')[20].value;
//					console.log(scope.seedParams);

					scope.$parent.seedTopListService.angularCallAjaxGetPost('post', '/api/seeds/edit' ,scope.seedParamsId, scope.seedParams, function(data, status) {
						console.log(data);
					});
				};
			}
		}
	});
}